package org.lyd.spring.tx.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;

/**
 * @Author:lyd
 **/
@Component
public class AccountDao {
    @Autowired
    JdbcTemplate jdbcTemplate;

    //根据username扣减账户余额
    public void deductionAccountByUsername(String username, BigDecimal amount) {
        String sql = "update account set balance = balance - ? where username = ?";
        jdbcTemplate.update(sql, amount, username);
    }

}
